if (islogin()) {
    $.post({
        url:'../../requests/teacher/select_classes.php',
        success:function (data) {
            for (var i = 0; i < data.length; i++) {
                var dom="<option value='"+data[i].num+"'>"+data[i].name+"</option>";
                $("select[name='class']").append(dom);
            }
        }
    });

    $('#add').click(function () {
        var fd=new FormData($('#form_notice')[0]);
        if (check()) {
            $.post({
                url:'../../requests/teacher/add_notice.php',
                data:fd,
                processData: false,
                contentType: false,
                success:function (data) {
                    if (data == '1') {
                        $$.alert('发布成功！');
                    }
                    else if (data == '0') {
                        $$.alert("发布失败！");
                    }
                }
            });
        }
        else {
            $$.alert("标题不能为空！");
        }
    });
}
else window.location.href='../../index.html';
function check() {
    if ($("input[name='title']").val()==""){
        return false;
    }
    else return true;
}